﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/ContentFrame.master" AutoEventWireup="true" CodeBehind="Departments.aspx.cs" Inherits="ETD.WebManagement.Admin.SystemManage.Departments" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxLoadingPanel ID="loadingPanel" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManagerDefault">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="searchPanel" />
                    <telerik:AjaxUpdatedControl ControlID="rtlDepartments" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="rtlDepartments">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rtlDepartments" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>

        </AjaxSettings>
    </telerik:RadAjaxManager>
   
        <asp:Panel ID="SearchPanel" runat="server">
            <telerik:RadDockLayout ID="SearchRadDockLayout" runat="server">
                <telerik:RadDockZone ID="SearchRadDockZone" runat="server" Orientation="Vertical" BorderWidth="0"
                    Resizable="true">
                    <telerik:RadDock ID="SearchRadDock" runat="server" Title="搜索：" EnableDrag="false"
                        DockHandle="TitleBar" DockMode="Docked" EnableAnimation="true" EnableRoundedCorners="false">
                        <ContentTemplate>
                            <div class="searchPanel">
                                <div>
                                    <label>部门名称：</label>
                                    <telerik:RadTextBox ID="txtDepartmentName" Width="120px" runat="server"></telerik:RadTextBox>
                                </div>
                                <div>
                                    <label>备注：</label>
                                    <telerik:RadTextBox ID="txtRemark" Width="120px" runat="server"></telerik:RadTextBox>
                                </div>
                                <div>
                                    <telerik:RadButton runat="server" ID="btnSearch" OnClick="btnSearch_Click" Text="搜索"></telerik:RadButton>
                                </div>
                            </div>

                        </ContentTemplate>
                    </telerik:RadDock>
                </telerik:RadDockZone>
            </telerik:RadDockLayout>
            <div style="height: 10px;"></div>
        </asp:Panel>

     

      <telerik:RadTreeList ID="rtlDepartments" runat="server" OnNeedDataSource="rtlDepartments_NeedDataSource" ClientSettings-Selecting-AllowItemSelection="true"
        ParentDataKeyNames="ParentDepartmentID" DataKeyNames="DepartmentID" AllowPaging="true" PageSize="1000" GridLines="Both"
        AutoGenerateColumns="false" AllowSorting="true" OnItemUpdated="rtlDepartments_ItemUpdated" AllowMultiItemEdit="true" OnItemCommand="rtlDepartments_ItemCommand"
        OnUpdateCommand="rtlDepartments_UpdateCommand" OnInsertCommand="rtlDepartments_InsertCommand"
           EditMode="InPlace" ExpandCollapseMode="Combined">

        <EditFormSettings EditColumn-ButtonType="ImageButton">
            <FormMainTableStyle Width="500px" />
        </EditFormSettings>
        <Columns>

            <telerik:TreeListTemplateColumn DataField="Name" UniqueName="Name"
                HeaderText="菜单名称">
                <ItemStyle Width="300px" />
                <HeaderStyle Width="300px" />
                <ItemTemplate>
                    <%# Eval("DepartmentName")%>
                    <%--<telerik:RadTextBox ID="txtColumnName" Text='<%# Bind("DepartmentName")%>' Width="100%" runat="server"></telerik:RadTextBox>--%>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadTextBox ID="txtColumnName" Text='<%# Bind("DepartmentName")%>' Width="100%" runat="server"></telerik:RadTextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <telerik:RadTextBox ID="txtColumnName" Width="100%" runat="server"></telerik:RadTextBox>
                </InsertItemTemplate>
                <%--<HeaderStyle Width="300px"></HeaderStyle>--%>
            </telerik:TreeListTemplateColumn>
            <telerik:TreeListTemplateColumn DataField="Remark" UniqueName="Remark"
                HeaderText="备注">
                <ItemTemplate>
                    <%# Eval("Remark")%>
                    <%--<telerik:RadTextBox ID="txtColumnRemark" Text='<%# Bind("Remark")%>' Width="100%" runat="server"></telerik:RadTextBox>--%>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadTextBox ID="txtColumnRemark" Text='<%# Bind("Remark")%>' Width="100%" runat="server"></telerik:RadTextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <telerik:RadTextBox ID="txtColumnRemark" Text='<%# Bind("Remark")%>' Width="100%" runat="server"></telerik:RadTextBox>
                </InsertItemTemplate>
                <%--<HeaderStyle Width="300px"></HeaderStyle>--%>
            </telerik:TreeListTemplateColumn>
            
          

            <telerik:TreeListTemplateColumn DataField="OrderNumber" UniqueName="OrderNumber"
                HeaderText="序号">
                <ItemStyle Width="60px" />
                <HeaderStyle Width="60px" />
                <ItemTemplate>
                    <%# Eval("OrderNumber").ToString()%>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadNumericTextBox ID="txtColumnOrderNumber" NumberFormat-DecimalDigits="0" Value='<%# Eval("OrderNumber")!=null?double.Parse(Eval("OrderNumber").ToString()):0d %>' Width="100%" runat="server"></telerik:RadNumericTextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <%--<telerik:RadTextBox ID="txtColumnDescription" Text='<%# Bind("OrderNumber")%>' Width="100%" runat="server"></telerik:RadTextBox>--%>
                    <telerik:RadNumericTextBox ID="txtColumnOrderNumber" NumberFormat-DecimalDigits="0" Value="0" Width="100%" runat="server"></telerik:RadNumericTextBox>
                </InsertItemTemplate>
                <%--<HeaderStyle Width="300px"></HeaderStyle>--%>
            </telerik:TreeListTemplateColumn>
        
           
            <telerik:TreeListTemplateColumn DataField="DepartmentID" UniqueName="DepartmentID"
                HeaderText="主键ID">
                <ItemStyle Width="60px" />
                <HeaderStyle Width="60px" />
                <ItemTemplate>
                    <%# Eval("DepartmentID").ToString()%>
                </ItemTemplate>
                <EditItemTemplate>
                    <%# Eval("DepartmentID").ToString()%>
                </EditItemTemplate>
                <%--<HeaderStyle Width="100px"></HeaderStyle>--%>
            </telerik:TreeListTemplateColumn>
            <telerik:TreeListTemplateColumn DataField="ParentDepartmentID" UniqueName="ParentDepartmentID"
                HeaderText="父主键ID">
                <ItemStyle Width="60px" />
                <HeaderStyle Width="60px" />
                <ItemTemplate>
                    <%# Eval("ParentDepartmentID")!=null?Eval("ParentDepartmentID").ToString():"--"%>
                </ItemTemplate>
                <EditItemTemplate>
                    <%# Eval("ParentDepartmentID")!=null?Eval("ParentDepartmentID").ToString():"--"%>
                </EditItemTemplate>
                <HeaderStyle Width="100px"></HeaderStyle>
            </telerik:TreeListTemplateColumn>
            <%--  <telerik:TreeListBoundColumn DataField="PermissionName" UniqueName="Price"
                HeaderText="Price">
                <ItemStyle HorizontalAlign="Right"></ItemStyle>
            </telerik:TreeListBoundColumn>--%>
            <telerik:TreeListEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" HeaderText="操作">
                <ItemStyle Width="100px" />
                <HeaderStyle Width="100px" />
            </telerik:TreeListEditCommandColumn>
            <%--<telerik:TreeListBoundColumn DataField="ParentID" UniqueName="ParentID" HeaderText="Parent Category ID">
            </telerik:TreeListBoundColumn>--%>

            <telerik:TreeListTemplateColumn HeaderText="删除" UniqueName="txtColDescription"
                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                <ItemStyle Width="60px" />
                <HeaderStyle Width="60px" />
                <ItemTemplate>
                    <a class="gridActionButton" onclick="rtlDepartmentsOnDeleteCommand(this,'<%#Eval("DepartmentID").ToString() %>');">删除</a>
                    <asp:Button ID="lbtnDeleteHiden" CssClass="hidden" runat="server" CommandName="Delete" />
                </ItemTemplate>
            </telerik:TreeListTemplateColumn>
        </Columns>

    </telerik:RadTreeList>
   
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            var departmentEditPageUrl = '<%=ResolveClientUrl("/Admin/SystemManage/DepartmentEdit.aspx?DepartmentID=") %>';
            var rtlDepartments = null;
            $(document).ready(function () {
                rtlDepartments = $find('<%=rtlDepartments.ClientID %>');
            });



            function rtlDepartmentsOnCommand(sender, eventArgs) {
                //retrieve the current commandName and commandArgument
                var commandName = eventArgs.get_commandName();
                if (commandName == "InitInsert") {
                    rtlDepartmentsOnInsertCommand(eventArgs);
                }
                else if (commandName == "Edit") {

                }

                //eventArgs.set_cancel(true); //cancel the command
            }
            function rtlDepartmentsOnInsertCommand(eventArgs) {
                var addUrl = departmentEditPageUrl + "-1";
                DefaultWindow.openWindow('添加部门', addUrl, 800, 500);
                eventArgs.set_cancel(true);
            }
            function rtlDepartmentsOnEditCommand(departmentID) {
                var editUrl = departmentEditPageUrl + departmentID;
                DefaultWindow.openWindow('编辑部门', editUrl, 800, 500);
                eventArgs.set_cancel(true);
            }
            function rtlDepartmentsOnDeleteCommand(self, departmentID) {
                onDeleteRadconfirm('确定要删除吗？', function (arg) {
                    if (arg) {
                        $(self).next().click();
                    }
                });
            }

            function refreshPageWithState() {
                var grid = rtlDepartments.get_masterTableView();
                grid.rebind();
            }

        </script>

    </telerik:RadCodeBlock>
</asp:Content>
